#ifndef CUSTOMITEM_H
#define CUSTOMITEM_H

#include <QWidget>
#include <QStyledItemDelegate>
#include <QLineEdit>
#include <QRegExp>
#include <QDebug>
#include <QDoubleValidator>
#include <QTableWidget>

class CustomItemDelegrate : public QStyledItemDelegate
{
    Q_OBJECT
public:
    CustomItemDelegrate(const QRegExp& regExp, QObject* parent = nullptr);
    ~CustomItemDelegrate(void);
    QWidget *createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
    void setEditorData(QWidget* editor, const QModelIndex& index ) const;
    void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index ) const;
    bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index);
    bool eventFilter(QObject *editor, QEvent *event);

public slots:
    void textChanged(QString ch);
private:
    QTableWidget *tbwig;
    QRegExp m_regExp;

};

#endif // CUSTOMITEM_H
